home *** CD-ROM | disk | FTP | other *** search
- Unit TimeBomb(897);
-
- {$U-}
-
- INTERFACE
-
- Uses MemTypes,Quickdraw,OSIntf,ToolIntf,PackIntf;
-
- Function TimeTest(numSecs: longInt) : Boolean;
-
- IMPLEMENTATION
-
- VAR
-
- Error : Integer;
- StartDate : LongInt;
- CurrDate : LongInt;
- FinalTicks : LongInt;
-
-
- Function TimeTest;
-
- Const
-
- ResType = 'TDAT';
- SecsToMin = 86400;
-
- Type
- TimeHandle = ^TimePtr;
- TimePtr = ^TimeStruct;
- TimeStruct = Record
- Old : LongInt;
- New : LongInt;
- Other : LongInt;
- OldString : Str255;
- NewString : Str255;
- End;
- Var
- TimeCheck : TimeHandle;
- BlankHandle : Handle;
- String1 : Str255;
- String2 : Str255;
-
-
- Begin
- GetDateTime(CurrDate);
- TimeCheck := TimeHandle(GetResource(ResType,0));
- If TimeCheck = Nil then
-
- { --------------------------------
- We cannot find a Resource so we
- Create one. This is only used
- Once.
- -------------------------------- }
-
- Begin
- TimeCheck := TimeHandle(NewHandle(SizeOf(TimeStruct)));
- TimeCheck^^.Old := CurrDate;
- IUDateString(CurrDate,LongDate,String1);
- IUTimeString(CurrDate,TRUE,String2);
- String1 := String1 + String2 + ' ';
- TimeCheck^^.OldString := String1;
- AddResource(Handle(TimeCheck),ResType,0,'');
- WriteResource(Handle(TimeCheck));
- Error := ResError;
- End;
-
- { Now Check to see if time has been exceeded }
-
- StartDate := TimeCheck^^.Old;
- FinalTicks := NumSecs + StartDate;
-
- If CurrDate > FinalTicks then
- Begin
- TimeTest := True;
- end
- Else
- Begin
- TimeTest := False;
- End;
-
- {If we have an Error trying to access the Resource file
- i.e. Write Protected, then we have a time exceed = true }
-
- If ResError <> 0 then TimeTest := True;
- End;
-
-
- Begin
- End.